//创建 store ，是redux 的仓库，保存 项目的 公共的 状态值的
import { createStore, applyMiddleware } from 'redux';
//引入中间件
import thunk from 'redux-thunk'
import logger from 'redux-logger';
import { composeWithDevTools } from 'redux-devtools-extension';
//需要纯函数  , 接收旧的状态值和动作，返回新的状态值； 专门修改状态值的
import reducer from './reducers';
//创建仓库并输出
// export default createStore(reducer, composeWithDevTools(applyMiddleware(thunk, logger)));
//引入 持久化插件
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
const persistConfig = {
    key: 'root',
    storage: storage,
    stateReconciler: autoMergeLevel2 // 查看 'Merge Process' 部分的具体情况
};
const myPersistReducer = persistReducer(persistConfig, reducer)
const store = createStore(myPersistReducer, composeWithDevTools(applyMiddleware(thunk, logger)));
export const persistor = persistStore(store)
export default store;